import logging
from homework.Base.Base import Base
import pytest,yaml,os

def read_yaml():
    with open(r'C:\Users\LENOVO\PycharmProjects\AutoWMS\homework\data.yaml',encoding='utf-8') as f:
        return yaml.safe_load(f)

class Test_Case:
    logging.info('starts')
    @pytest.fixture(scope='session')
    def api(self):
        return Base()

    @pytest.mark.parametrize('data',read_yaml())
    def test_01_add(self,api,data):
        tou = {'Cookie':'JSESSIONID=8AB8C4A2A9F8B1A37F29D5231D901A9F'}
        date = {'platformCode': data['platformCode'],'platformName': data['platformName']}
        add = api.post(
            path='jeewms/baPlatformController.do?doAdd',
            headers=tou,
            data=date
        )
        print(add.json())
        logging.info(add.json())

    @pytest.mark.parametrize('data', read_yaml())
    def test_02_add(self,api,data):
        tou = {'Cookie': 'JSESSIONID=8AB8C4A2A9F8B1A37F29D5231D901A9F'}
        date = {'platformCode': data['platformCode'], 'platformName': data['platformName']}
        add = api.post(
            path='jeewms/baPlatformController.do?doAdd',
            headers=tou,
            data=date
        )
        print(add.json())